const state = {
  currentIndex: 1,
  currentDistrictId: 0,
  currentCategoryId: 0,
}

const mutations = {
  SET_CURRENT_INDEX(state, value){
    if(typeof value !== 'number'){
      throw new Error('currentIndex must be a number')
    }
    state.currentIndex = value
  },
  SET_CATEGORY_ID(state, value){
    if(typeof value !== 'number'){
      throw new Error('currentCategoryId must be a number')
    }
    state.currentCategoryId = value
  },
  SET_DISTRICT_ID(state, value){
    if(typeof value !== 'number'){
      throw new Error('currentDistrictId must be a number')
    }
    state.currentDistrictId = value
  },
}

const actions = {
  setCurrentIndex({ commit }, value){
    commit('SET_CURRENT_INDEX', value)
  },
  setCurrentCategoryId({ commit }, value){
    commit('SET_CATEGORY_ID', value)
  },
  setCurrentDistrictId({ commit }, value){
    commit('SET_DISTRICT_ID', value)
  },
}

export default {
  state,
  mutations,
  actions
}
